﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using InfoPick.Lib.Entity;
using InfoPick.Lib.Tools;

namespace InfoPick.Lib.StringResolve
{
    /// <summary>
    /// 对应于GMDDF和GMODF
    /// </summary>
    public class GMN7LNKResolver
    {
        public static List<GMN7LNK> ResolveList(string str)
        {
            List<GMN7LNK> list = new List<GMN7LNK>();
            if (!string.IsNullOrEmpty(str))
            {
                var table = StringTools.GetTable(str, "查询MTP3链路", "(结果个数");
                foreach (var item in table)
                {
                    var obj = GMN7LNK.Create(item);
                    if (obj != null)
                        list.Add(obj);
                }
                 
            }

            //排序
            var grp = list.GroupBy(c => c.Direction);
            foreach (var g in grp)
            {
                int idx = 1;
                foreach (var item in g.OrderBy(c=>c.NameNum))
                {
                    item.Id = idx++;
                }
               
            }
            return list;
        }
    }
}
